import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrganVO, OrganForm, OrganQuery } from '@/api/shopping/organ/types';

/**
 * 查询易货机构列表
 * @param query
 * @returns {*}
 */

export const listOrgan = (query?: OrganQuery): AxiosPromise<OrganVO[]> => {
  return request({
    url: '/shopping/organ/list',
    method: 'get',
    params: query
  });
};


/**
 * 查询机构列列表( 不分页的 下拉框使用)
 * @param query
 * @returns {*}
 */

export const noPageListOrgan = (query?: OrganQuery): AxiosPromise<OrganVO[]> => {
  return request({
    url: '/shopping/organ/noPage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询易货机构详细
 * @param id
 */
export const getOrgan = (id: string | number): AxiosPromise<OrganVO> => {
  return request({
    url: '/shopping/organ/' + id,
    method: 'get'
  });
};

/**
 * 新增易货机构
 * @param data
 */
export const addOrgan = (data: OrganForm) => {
  return request({
    url: '/shopping/organ',
    method: 'post',
    data: data
  });
};

/**
 * 修改易货机构
 * @param data
 */
export const updateOrgan = (data: OrganForm) => {
  return request({
    url: '/shopping/organ',
    method: 'put',
    data: data
  });
};

/**
 * 删除易货机构
 * @param id
 */
export const delOrgan = (id: string | number | Array<string | number>) => {
  return request({
    url: '/shopping/organ/' + id,
    method: 'delete'
  });
};
